home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / tabvie.zip / README.TXT < prev    next >
Text File  |  1994-04-13  |  7KB  |  202 lines

  1. Description of CTabView
  2.  
  3. Written by Gerry High
  4. 74750,2456 CIS
  5.  
  6. Revision History
  7. Version    Date
  8. 1.2     4/13/94
  9.     Added Vertical tabs (left, right).  Some work was done by Douglas Brown
  10.     Allow runtime setting of tab margins, height, style.
  11.     Modified ALT+mnemonic view switching to not require accelerator definitions.
  12.     Changed "toupper" to "AnsiUpper".
  13.     Changed hardcoded RGB values to use GetSysColor.
  14.     Fixed bug with OnMouseActivate.
  15.  
  16. Version    Date
  17. 1.1    3/16/94
  18.     Removed extra frame in each view.
  19.     Added code for ALT+Mnemonic view switching.
  20.     Added suggestions from various people in the forum.
  21.     Added MS Word 6.0 look to tabs (compliments of David Hollifield).
  22.  
  23. Version    Date
  24. 1.0    2/15/94 Initial posting
  25.                         
  26. Description
  27. This is a sample application using the CTabView class.  Expand the zip file
  28. using the -d option and use VC++ to build the project.  The project uses the DLL version of MFC (mfc250d.dll) which should be in your windows\system directory.
  29.  
  30. To use the CTabView class in your own projects do the following:
  31.  
  32. 1.  Subclass CTabView with the class you wish to manage your tabs (e.g. 
  33.      CMainView : public CTabView ...  You should provide an "OnInitialUpdate" member
  34.      method.
  35. 2.  Add tabview.cpp and your subclass of CTabView to your project.
  36. 3.  Modify the application class to use your view class.  Modify the include file name to be your
  37.      view.h.  Modify your document template to specify the new view (e.g.)
  38.     
  39.     AddDocTemplate(new CMultiDocTemplate(IDR_TABTYPE,
  40.         RUNTIME_CLASS(CTabDoc),
  41.         RUNTIME_CLASS(CMDIChildWnd),    // standard MDI child frame
  42.         RUNTIME_CLASS(CMainView)));    // your view goes here
  43.             
  44. 4.  In your  OnInitialUpdate method add your views to the CTabView class using the method     
  45.      "addTabView"
  46.  
  47.     addTabView(RUNTIME_CLASS(COrderView),GetDocument(),"&Options",this,);
  48.     addTabView(RUNTIME_CLASS(CDrawView),GetDocument(),"&Graphics",this,
  49.             TRUE,FALSE);
  50.  
  51.      Finally, call the CTabView "OnInitialUpdate" method from your OnInitialUpdate method.
  52.  
  53.         CTabView::OnInitialUpdate();
  54.  
  55.      An example from mainview.cpp is shown below:
  56.  
  57.     void CMainView::OnInitialUpdate()
  58.     {
  59.         COrderView* pOrderView = (COrderView*)         
  60.             addTabView(RUNTIME_CLASS(COrderView),GetDocument(),
  61.                 "&Options");
  62.         ASSERT(pOrderView != NULL);
  63.         pOrderView->m_pTabView = this;
  64.  
  65.         CDrawView* pDrawView = (CDrawView*)     
  66.             addTabView(RUNTIME_CLASS(CDrawView),GetDocument(),
  67.             "&Graphics",TRUE,FALSE);
  68.         ASSERT(pDrawView != NULL);
  69.         pDrawView->m_pTabView = this;
  70.  
  71.         CEditVw* pEditView = (CEditVw*)     
  72.             addTabView(RUNTIME_CLASS(CEditVw),GetDocument(),
  73.             "&Edit",TRUE,FALSE);
  74.         ASSERT(pEditView != NULL);
  75.         pEditView->m_pTabView = this;
  76.  
  77.         CTabView:OnInitialUpdate();
  78.     }
  79.  
  80.      This example creates three tabs (Options, Graphics, and Edit).  The last thing done in the 
  81.      OnInitialUpdate method is to call the base class OnInitialUpdate method.
  82.  
  83. 5.  If you override the OnDraw method of CTabView you must call the CTabView::OnDraw 
  84.      method as well.
  85. 6.  If you override the OnSize method of CTabView you must call the CTabView::OnSize 
  86.      method as well.
  87.  
  88. Known Problems/Limitations
  89. 1.  A disabled tab currently uses the system color COLOR_GRAYTEXT; this may not yield a color that will work for all color schemes and result in the text being invisible.  In the future I will fix this to use the GrayString function.
  90. 2.  The Chicago look is only implemented for the TABSONTOP orientation.
  91. 3.  For vertical orientations the underline is not drawn for the tab mnemonic.  The reason for this is that TextOut doesn't support automatic underlining.
  92.  
  93. Disclaimer, etc.
  94. Any questions, problems, suggestions, etc. should be directed to the author Gerry High 74750,2456 CIS.  Feel free to use this in your own programs.  This class is freeware and is provided as is.  In the near future I may update this class to support multi-row tabs and dialog support.  Other possibilities include tear-off tabs and owner draw tabs.  
  95.  
  96.  
  97.  
  98.  
  99. Class Reference
  100.  
  101. class CTabView : public CView
  102.  
  103. ______________________________________________________________
  104. CTabView::addTabView
  105.  
  106.         virtual CView*     addTabView(CRuntimeClass* pViewClass,
  107.             CDocument* pDoc, char* tabLabel, BOOL border = FALSE,
  108.             BOOL show = TRUE, int tabWidth = 100);
  109.  
  110.         pViewClass    Pointer to CRuntimeClass of child view.
  111.         pDoc        Pointer to document.
  112.         pTabLabel    Pointer to the string for the tab label.
  113.         border        Requests whether a border is to be drawn around the view.
  114.         show        Requests whether to view is to be shown.
  115.         tabWidth    Specifies the width of the tab in pixels.
  116.  
  117. Remarks    Call this function to add a tab.
  118.  
  119. ______________________________________________________________
  120. CTabView::doSysCommand
  121.  
  122.         void doSysCommand(UINT nID, long lParam);
  123.  
  124. Remarks    Call this function from an OnSysCommand handler to pass "ALT-mnemonic" 
  125.         keys through from the child view for view switching.
  126.  
  127. Example    void CDrawView::OnSysCommand(UINT nID, long lParam)
  128.         {
  129.             if(m_pTabView->doSysCommand(nChar,lParam))
  130.                 return;
  131.             CScrollView::OnSysCommand(nChar,lParam);
  132.         }
  133.  
  134. ______________________________________________________________
  135. CTabView::enableView
  136.  
  137.         void enableView(int index, BOOL bEnable = TRUE);
  138.  
  139.         index        Specifies the zero based index of the tab to be enable or 
  140.                 disabled.
  141.         bEnable    Specifies whether the given tab is to be enabled or disabled.
  142.  
  143. Remarks    Call this function to enable or disable a tab.
  144.  
  145. Example    enableView(1, FALSE); //disable tab 1
  146.  
  147. ______________________________________________________________
  148. CTabView::setFrameBorderOn
  149.  
  150.         void setFrameBorderOn(BOOL bOn = TRUE);
  151.  
  152.         bOn    Specifies whether the frame border is to be drawn.
  153.  
  154. Remarks    Call this function to turn on or off the tab frame.
  155.  
  156. ______________________________________________________________
  157. CTabView::setLAF
  158.  
  159.         void setLAF(eLookAndFeel LAF);
  160.  
  161.         LAF    Is a enum of type eLookAndFeel.  Must be either LAF_MSWORD or
  162.             LAF_CHICAGO.
  163.  
  164. Remarks    Call this function to set the look and feel to either Chicago or MS Word.
  165.  
  166. ______________________________________________________________
  167. CTabView::setMargin
  168.  
  169.         void setMargin(int margin);
  170.  
  171.         margin        The margin width in pixels.
  172.  
  173. Remarks    Call this function to set the margin around the tab frame.
  174.  
  175. ______________________________________________________________
  176. CTabView::setTabHeight
  177.  
  178.         void setTabHeight(int height);
  179.  
  180.         height        The tab height in pixels.
  181.  
  182. Remarks    Call this function to set the height of the tabs.
  183.  
  184. ______________________________________________________________
  185. CTabView::setTabPosition
  186.  
  187.         void setTabPosition(eTabPosition tabPosition);
  188.  
  189.         tabPosition    Specifies the position of the tabs.  Must be one of
  190.                 TABSONTOP, TABSONLEFT, TABSONLEFTBOT,                         TABSONRIGHT,  TABSONRIGHTBOT, or TABSONBOTTOM.
  191.  
  192. Remarks    Call this function to set the postiton of the tabs.
  193.  
  194. ______________________________________________________________
  195. CTabView::switchTab
  196.  
  197.         void switchTab(int viewIndex);
  198.  
  199.         viewIndex    Specifies the zero-based index of the tab to be switched to.
  200.  
  201. Remarks    Call this function to switch between different tabs.
  202.